<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticlesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title', 200)->comment('标题');
            $table->string('subtitle', 200)->comment('副标题');
            $table->string('tag')->comment('标签');
            $table->text('profile')->comment('简介');
            $table->text('content')->comment('内容');
            $table->string('hash')->comment('附件关联hash值');
            $table->string('url', 200)->comment('跳转url，用于外链');
            $table->string('cover', 200)->comment('封面图');

            $table->unsignedInteger('category_id')->comment('文章分类ID');
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('articles');
    }
}
